package com.codeoss.framework.view.renderer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.component.Component;
import com.codeoss.framework.view.component.LinkRecord;
import com.codeoss.framework.view.service.impl.LinkRecordComponentService;

@Service("linkrecordRenderer")
public class LinkRecordRenderer extends CommonComponentRenderer {
	@Autowired
	private LinkRecordComponentService linkRecordComponentService;
	protected void startRenderView(YunContext yunContext, Component component, ViewSerializeMap viewSerializeMap) {
		super.startRenderView(yunContext, component, viewSerializeMap);
		LinkRecord linkRecord=(LinkRecord)component;
		viewSerializeMap.put("label", linkRecord.getLabel());
		viewSerializeMap.put("refPageCode", linkRecord.getRefPageCode());
		viewSerializeMap.put("model", yunContext.getMasterModel());
	}
	

	@Override
	protected PropSerializeMap startRenderProp(YunContext yunContext, Component component, ViewPropMap viewPropMap) {
		PropSerializeMap propSerializeMap = super.startRenderProp(yunContext, component, viewPropMap);
		long count=linkRecordComponentService.getCount(yunContext, component);
		propSerializeMap.put("count", count);
		propSerializeMap.put("currentId", yunContext.getCurrentId());
		return propSerializeMap;
	}
}
